package com.tongji.quickCRUDQ.dao.jdbc;

import java.util.ArrayList;
import java.util.List;

import com.tongji.quickCRUDQ.dao.BaseDao;
import com.tongji.quickCRUDQ.dao.id.IdGenerator;
import com.tongji.quickCRUDQ.dao.jdbc.ColumnDao;
import com.tongji.quickCRUDQ.dao.jdbc.CommonDao;
import com.tongji.quickCRUDQ.dao.jdbc.DatabaseFormat;
import com.tongji.quickCRUDQ.dao.jdbc.TableDao;
import com.tongji.quickCRUDQ.define.Row;
import com.tongji.quickCRUDQ.model.CommonBean;

public class BaseDaoJdbc implements BaseDao{
	private CommonDao commonDao;
	private ColumnDao columnDao;
	private TableDao tableDao;
	private IdGenerator idGenerator;
	private DatabaseFormat databaseFormat;
	
	public Row getRow(String tableName){
		List columns=columnDao.getColumnList(tableName);
		Row row=new Row();
		row.addColumnList(columns);
		return row;
	}
	
	

   public CommonBean createBean(String tableName){
	 Row row=this.getRow(tableName);
	 CommonBean bean=new CommonBean("",row.getDistinctColumnList(),new ArrayList(),this.getDatabaseFormat());
     return bean;
   }

   public CommonBean createBean(String tableName,String beanName){
	 Row row=this.getRow(tableName);
	 CommonBean bean=new CommonBean(beanName,row.getDistinctColumnList(),new ArrayList(),this.getDatabaseFormat());
    return bean;
  }

	public CommonDao getCommonDao() {
		return commonDao;
	}

	public void setCommonDao(CommonDao commonDao) {
		this.commonDao = commonDao;
	}
	

	/**
	 * @return Returns the columnDao.
	 */
	public ColumnDao getColumnDao() {
		return columnDao;
	}
	/**
	 * @param columnDao The columnDao to set.
	 */
	public void setColumnDao(ColumnDao columnDao) {
		this.columnDao = columnDao;
	}
	/**
	 * @return Returns the idGenerator.
	 */
	public IdGenerator getIdGenerator() {
		return idGenerator;
	}
	/**
	 * @param idGenerator The idGenerator to set.
	 */
	public void setIdGenerator(IdGenerator idGenerator) {
		this.idGenerator = idGenerator;
	}
	/**
	 * @return Returns the databaseFormat.
	 */
	public DatabaseFormat getDatabaseFormat() {
		return databaseFormat;
	}
	/**
	 * @param databaseFormat The databaseFormat to set.
	 */
	public void setDatabaseFormat(DatabaseFormat databaseFormat) {
		this.databaseFormat = databaseFormat;
	}



	/**
	 * @return the tableDao
	 */
	public TableDao getTableDao()
	{
		return tableDao;
	}



	/**
	 * @param tableDao the tableDao to set
	 */
	public void setTableDao(TableDao tableDao)
	{
		this.tableDao = tableDao;
	}
}
